// 线样式枚举
const lineTypeEnum = [
  { key: '__________', value: 'solid' },
  { key: '----------', value: 'dashed' },
  { key: '................', value: 'dotted' },
];
// 线条粗细
function lineType(params) {
  const { name, value } = params || {};
  return {
    name: name || '样式',
    code: 'type',
    value: value || 'solid',
    type: 'Select',
    enumValue: lineTypeEnum,
  };
}

export default {
  name: '圈选层',
  code: 'custom_map_group_select',
  version: '1.0.0',
  config: [
    {
      name: '圈选样式',
      code: 'circle',
      children: [
        {
          name: '背景颜色',
          code: 'bgColor',
          value: 'rgba(1, 140, 255, 0.4)',
          type: 'ColorSelector',
        },
        {
          name: '边框颜色',
          code: 'lineColor',
          value: '#018CFF',
          type: 'ColorSelector',
        },
        {
          name: '边框宽度(1~99)',
          code: 'lineWidth',
          value: 3,
          min: 1,
          max: 99,
          type: 'InputNumber',
          unit: 'px',
        },
        lineType(),
      ],
    },
    {
      name: '按钮样式',
      code: 'btn',
      children: [
        {
          name: '文本设置',
          code: 'font',
          value: {
            fontSize: 20,
            fontFamily: 'siyuan',
            color: '#FFF',
            fontWeight: 'normal',
          },
          type: 'FontGroup',
        },
        {
          name: '背景颜色',
          code: 'backgroundColor',
          value: 'rgba(85, 85, 85, 0.6)',
          type: 'ColorSelector',
        },
        {
          name: '边框设置',
          code: 'border',
          children: [
            {
              name: '边框线条粗细',
              code: 'borderWidth',
              value: 2,
              type: 'InputNumber',
              max: 99,
              min: 1,
            },
            {
              name: '边框线条色',
              code: 'borderColor',
              value: '#4A4A4A',
              type: 'ColorSelector',
            },
            lineType(),
            {
              name: '圆角设置',
              code: 'borderRadius',
              value: '10',
              type: 'InputNumber',
              max: 99,
              min: 1,
            },
          ],
        },
        {
          name: '按钮位置',
          code: 'position',
          children: [
            {
              name: '横坐标',
              code: 'left',
              value: '20',
              type: 'InputNumber',
              min: 0,
              unit: 'px',
            },
            {
              name: '纵坐标',
              code: 'top',
              value: '20',
              type: 'InputNumber',
              min: 0,
              unit: 'px',
            },
          ],
        },
      ],
    },
  ],
  data: {
    field: [
      { name: 'lng', mapper: 'lng' },
      { name: 'lat', mapper: 'lat' },
      { name: 'distance', mapper: 'distance' },
    ],
    type: 1,
    value: JSON.stringify([
      {
        lng: 116,
        lat: 39,
        distance: 100,
      },
    ]),
  },
  events: {
    click: {
      description: '标签点击响应事件',
      fields: {
        lng: {
          mapper: '',
          description: '经度',
          value: 116,
        },
        lat: {
          mapper: '',
          description: '纬度',
          value: 39,
        },
        distance: {
          mapper: '',
          description: '距离（公里）',
          value: 100,
        },
      },
    },
  },
};
